package cn.xs.user.dao.impl;


import org.apache.commons.dbutils.handlers.BeanHandler;

import cn.xs.core.dao.impl.BaseDaoImpl;
import cn.xs.user.dao.AdminDao;
import cn.xs.user.entity.Admin;

public class AdminDaoImpl extends BaseDaoImpl<Admin> implements AdminDao {

	@Override
	public void save(Admin entity) {
		try{
			String sql="insert into t_admin values(?,?,?);";
			Object[] params = {entity.getId(),entity.getAccount(),entity.getPassword()};
			getQueryRunner().update(sql,params);
		}catch (Exception e) {
			throw new RuntimeException(e);
		}
	}

	public Admin findAdminByAccAndPwd(String account, String password) {
		try{
			String sql="select * from t_admin where account = ? and password = ?;";
			Object[] params = {account,password};
			return (Admin) getQueryRunner().query(sql, new BeanHandler(Admin.class), params);
		}catch (Exception e) {
			throw new RuntimeException(e);
		}
	}

}
